package com.suray.wcs.web.system.controller.thread;

import com.suray.basic.wcs.utils.LoggerUtil;
import com.suray.basic.wcs.utils.WcsFuncUtil;
import com.suray.wcs.service.resmap.WriteMap;
import com.suray.wcs.service.test.base.BaseThread;
import org.springframework.stereotype.Component;

import java.io.IOException;

//@Component
public class WriteMapUtil {
    private static volatile boolean writeMap;

    public static synchronized void writeMap() {
        writeMap = true;
    }

    private static synchronized boolean checkWriteMap() {
        if (writeMap) {
            writeMap = false;
            return true;
        }

        return false;
    }

    /**
     * 生成地图
     * @throws IOException
     */
    public static synchronized void generalMap() throws IOException {
        if (checkWriteMap()) {
            LoggerUtil.info("开始生成小车地图", WriteMapUtil.class);
            WriteMap.write();
            LoggerUtil.info("生成小车地图完成", WriteMapUtil.class);
        }
    }
}
